package com.hnkywl.sts.entity.cwgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.organ.Nbgs;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: lenovo
 * Date: 13-5-18
 * Time: 下午12:25
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "T_BIZ_QTPZ")
@Where(clause = "deleted!='1'")
public class Qtpz extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqQtpz", allocationSize = 1, sequenceName = "SEQ_BIZ_QTPZ")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqQtpz")
    private Long id;
    /**
     * 公司
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "NBGS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Nbgs nbgs;
    /**
     * 制单日期
     */
    private Date zdrq;
    /**
     * 字号
     */
    private String zh;
    /**
     * 附单据数
     */
    private Integer fdjs;
    /**
     * 状态 zt=0  暂存  zt=1 录入完全
     */
    private Integer zt = 0;
    /**
     * 备注
     */
    @Column(length = 4000)
    private String bz;
    /**
     * 借方合计
     */
    private Double jfhj = 0.0;
    /**
     * 贷方合计
     */
    private Double dfhj = 0.0;
    /**
     * 会计年
     */
    @Column(name = "jiuqi_acctyear")
    private Integer acctyear;
    /**
     * 生成久其凭证时提供的ID
     */
    @Column(name = "jiuqi_uuid")
    private String uuid;
    /**
     * 久其返回的凭证ID
     */
    @Column(name = "jiuqi_voucher_id")
    private String voucherId;
    /**
     * 久其返回的凭证号
     */
    @Column(name = "jiuqi_voucher_num")
    private Integer voucherNum;
    /**
     * “久其插入标示”代码   1=未导入,2=导入开始,3=导入成功
     */
    @Column(name = "jiuqi_insert_flag")
    private Integer insertFlag = 1;
    /**
     * "久其删除标示”代码   1=未删除,2=删除开始,3=删除成功
     */
    @Column(name = "jiuqi_delete_flag")
    private Integer deleteFlag = 1;

    /**
     * 凭证分录
     */
    @OneToMany(fetch = FetchType.LAZY)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "QTPZ_ID")
    @OrderBy("  jfje asc ")
    private List<Qtpzfl> qtpzflList;

    @Formula("(select t.zy from T_BIZ_QTPZFL t where t.QTPZ_ID=ID and t.deleted!=1 and rownum=1)")
    private String zy;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Nbgs getNbgs() {
        return nbgs;
    }

    public void setNbgs(Nbgs nbgs) {
        this.nbgs = nbgs;
    }

    public Date getZdrq() {
        return zdrq;
    }

    public void setZdrq(Date zdrq) {
        this.zdrq = zdrq;
    }

    public String getZh() {
        return zh;
    }

    public void setZh(String zh) {
        this.zh = zh;
    }

    public Integer getFdjs() {
        return fdjs;
    }

    public void setFdjs(Integer fdjs) {
        this.fdjs = fdjs;
    }

    public Integer getZt() {
        return zt;
    }

    public void setZt(Integer zt) {
        this.zt = zt;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public Integer getAcctyear() {
        return acctyear;
    }

    public void setAcctyear(Integer acctyear) {
        this.acctyear = acctyear;
    }

    public Double getJfhj() {
        return jfhj;
    }

    public void setJfhj(Double jfhj) {
        this.jfhj = jfhj;
    }

    public Double getDfhj() {
        return dfhj;
    }

    public void setDfhj(Double dfhj) {
        this.dfhj = dfhj;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getVoucherId() {
        return voucherId;
    }

    public void setVoucherId(String voucherId) {
        this.voucherId = voucherId;
    }

    public Integer getVoucherNum() {
        return voucherNum;
    }

    public void setVoucherNum(Integer voucherNum) {
        this.voucherNum = voucherNum;
    }

    public Integer getInsertFlag() {
        return insertFlag;
    }

    public void setInsertFlag(Integer insertFlag) {
        this.insertFlag = insertFlag;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public List<Qtpzfl> getQtpzflList() {
        return qtpzflList;
    }

    public void setQtpzflList(List<Qtpzfl> qtpzflList) {
        this.qtpzflList = qtpzflList;
    }
}
